package liu.db;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.SimpleFormatter;

import org.junit.Test;

public class indexTime {
	
	@Test
	public void indexTest() throws Exception {
		
		String sql="select ID,NAME from dashujutest where NAME=?";
		Connection conn = DBUtil.getConn();
		
		SimpleDateFormat format=new SimpleDateFormat("ss.SSS");
		Date date=new Date();
		String f1= format.format(date);
		
		PreparedStatement ps = conn.prepareStatement(sql);
		ps.setString(1,"978329");
		ResultSet rs = ps.executeQuery();
		
		Date date2=new Date();
		String f2= format.format(date2);
		Double a=Double.parseDouble(f2)-Double.parseDouble(f1);
		
		System.out.println("查询时间：="+a);
		while(rs.next()){
			int id = rs.getInt("ID");
			String name = rs.getString("NAME");
			System.out.println(id+":"+name);
		}
		
		
		
		
		
	}

}
